home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / diskmags / 3565-4.665 / dmg-4385 / issue_10 / 22.pne < prev    next >
Text File  |  1987-04-21  |  12KB  |  269 lines

  1.  
  2.                            Customising STOS
  3.                            ~~~~~~~~~~~~~~~~
  4.  
  5.                           Part 2: FONTastic!
  6.             (Yeh crummy, but you try writing sub headings!)
  7.  
  8.  
  9.  
  10. Why use different fonts? I mean what's wrong with the standard font?
  11.  
  12. Good question. (glad you asked it aren't you) There are really two
  13. types of fonts. 'Them thar readin fonts' and the display fonts. Reading
  14. fonts naturally enough are used for reading large amounts of text.
  15. They're designed to be read easily and are consequently very boring.
  16. The display fonts are for those situations where you need impact.
  17. Imagine if you used the default character set for the title screen in
  18. your latest game - laughter would be heard for miles. A bog standard
  19. 8x8 font simply can't hack it.
  20.  
  21. Another reason for changing fonts is to add character to your program.
  22. Using an unusual font can make your proggy stand out from the crowd.
  23. And that can't be bad.
  24.  
  25. An important point here is don't mix the two fonts up. If you are going
  26. to give the reader a lot of text to read make it simple. A general rule
  27. of thumb is; if the text is more than 10 lines then use a reading font.
  28.  
  29. Some basics about fonts in STOS.
  30.  
  31. Using alternative fonts is fairly easy in STOS (unlike other languages)
  32. you only have to open a window and assign a new font.
  33.  
  34. On the subject of windows; Due to a typing error on my part I got a
  35. window with no border! Excellent. Opening a window without a border
  36. gives you back the two characters you normally lose when opening a
  37. window. Groovy! - just thought I'd share that. Oh to use it try
  38. this:(assumes medium res!)
  39.  
  40.         windopen 1,0,0,80,25,0
  41.                               \open without a border...
  42.  
  43. The manual doesn't mention this, but hey it's not perfect - by a long
  44. way.
  45.  
  46. Anyway back to fonts. STOS can hold an astonishing 10 fonts in memory
  47. at the same time, and thankfully they don't interfere with memory
  48. banks. These extra default fonts should be placed in the STOS and
  49. Compiler folders with the extensions .CR3 to .CR9 - in the manual it
  50. says that you should call the first additional font CR4 but it will
  51. need to be CR3. The reason - I think - is because STOS should have
  52. really came with 4 default character sets but only came with 3. Oh
  53. well. Always name the next font you are adding as; the biggest value of
  54. CRx +1. So if the biggest value you have is CR5 then the next
  55. additional font should be CR6.
  56.  
  57. The fonts in the STOS folder and the Compiler folder should match. If
  58. they don't then the Basic and compiled versions of your program will
  59. have a different font. This of course may be desirable, you can have a
  60. nice readable font for programming and a pretty but un-readable font
  61. for the compiled verson.
  62.  
  63. What's the difference between the .MBK file that is produced by the
  64. fonts accessory and the CR? font that is loaded as a system font?
  65.  
  66. I'm glad you're asking these questions, shows you're paying attention.
  67. All .MBK files have an 18 byte header which has the name 'LIONPOUBNK'
  68. and a few other bits of information such as the size of the bank etc.
  69. Once the file is loaded this header information is removed.
  70.  
  71. The CR? format file immediatly starts with the idenfier code which is
  72. $6071963, a leek(start(bank)) should return this value if it is truly a
  73. font file.
  74.  
  75. Once the font is in memory you can find out the size of it by using the
  76. following:
  77.  
  78. WIDTH=deek(start(BNK)+4)*8 : HEIGHT=deek(start(BNK)+6)
  79.  
  80. To change the default character sets you must load a bank holding a
  81. font into STOS. Then BSAVE it to the STOS or Compiler folder using a
  82. line like:
  83.  
  84.             bsave "8X8.CR1",start(5) to start(5)+length(5)
  85.  
  86. Where start(5) is the bank where the new font is stored and save it as
  87. the default medium resolution font.
  88.  
  89. When you reboot STOS the new font will be installed as the system font
  90. for the medium resolution, and can be used without the need to open a
  91. window. Nice. Doing the bsave bit is - simply - a pain in the bum, so
  92. on the disk is little accessory (F_SWITCH) that takes the tedium and
  93. typing errors out of it. It's straight forward to use and instructions
  94. are beside the program itself.
  95.  
  96. On the disk is a file called A_FONT.MBK this is the font that we are
  97. going to use as an example to replace the default set. It's a nice 8x8
  98. character set for the low or medium resolution.
  99.  
  100.         NOTE: DO NOT USE YOUR ORIGINAL SYSTEM DISK TO DO THIS!
  101.                        ALWAYS WORK ON A BACKUP..
  102.  
  103. 1. Boot up STOS and 'accload' the program F_SWITCH. It needn't be
  104.    loaded as an accessory but it was designed to be instantly
  105.    accessible from the STOS environment.
  106.  
  107. 2. Goto the heading 'File' on the menu bar and select 'Load .MBK'. A
  108.    file selector will appear prompting you to select a file. Locate
  109.    A_FONT.MBK and double click or 'Return' from the selector. After a
  110.    short pause there should be a bit of information about the currently
  111.    loaded font.
  112.  
  113.     To see what the font looks like goto 'View' on the menu bar. Any
  114.     mouse button or the keyboard will return to the main screen.
  115.  
  116. 3. At this point you can install the font as system font 1,2,3 or save
  117.    the font to the STOS or Compiler folders. In this example we will
  118.    change the medium res system font for the next boot up. Goto the
  119.    option 'Install' on the menu bar and select 'STOS Folder'  A
  120.    Fileselector will appear. Locate the the STOS folder and find the
  121.    file 8X8.CR1 and select it.
  122.  
  123. 4. Once the drive has stopped, re-boot STOS and your new font will now
  124.    be used. If you normally have the environment set to low res, you
  125.    will have to change to medium res to see the font
  126.  
  127. Any recognised font can be used in this manner from 8x8 to 32x32. The
  128. compiler option is identical to the STOS option but the font will only
  129. be used at compile time.
  130.  
  131. Okay so we can now change the default character sets without too much
  132. fuss. How about changing the font half way through the program. By that
  133. I mean (as an example) you have a two screen menu system based in low
  134. res. One screen gives you information about the program and the other
  135. lets you set parameters. Because these two screens are different in
  136. function we have decided it would be quite neat to give each screen a
  137. different character and a different font. Using the traditional STOS
  138. commands the program Would need to use windows. However there are a
  139. number of reasons for not using windows - speed for one, just try the
  140. music accessory to see how slow the windows are.
  141.  
  142. Windows do have a couple of advantages, the main one is lack of hassle
  143. as everything is taken care off. It's draw backs are that fonts can
  144. only be changed in one entire line. This is not always what you would
  145. want. GEM has a neat trick of being able to have different font
  146. combinations on the same line. On the disk is a little basic program
  147. called ONTHEFLY.BAS which may cause a bit of interest.
  148.  
  149. The program does a bit of brute jiggery to get the desired results in
  150. the 'install as system x' options and a brief explanation of what is
  151. happening in the program is needed.
  152.  
  153. Because the trap call for changing font addresses doesn't appear to
  154. work, a brute method of changing the fonts is required. STOS doesn't
  155. use the GEM fonts and so keeps a copy of it's fonts in memory
  156. somewhere. The somewhere can be found using trap 3. Specifically
  157. function 28 in trap 3. It can be used like this:
  158.  
  159. dreg(7)=28      ; The function called 'GET CHARSET'
  160.  
  161. dreg(0)=0       ; Which font do we want? 0=system font 1; Low Res
  162.                                          1=system font 2; Med Res
  163.                                          3=system font 3  High Res
  164.                                          4=system font 4
  165.                                          ~   ~     ~   ~
  166.                                          9=system font 9
  167.  
  168. trap 3          ; Do the trap call
  169.  
  170. and finally
  171.  
  172. CHARSET_ADDRESS=dreg(0) ; The function returns the character set
  173.                           address in register d0
  174.  
  175. In order to use the routine for your own nefarious purposes chop out
  176. this routine from the F_SWITCH program (it's been modified lightly) and
  177. just call it. Lines 520-560 holds the actual routine.
  178.  
  179. Line 520 get the address of the font that we want to switch. As the
  180. font location MAY move around it's best to call it every time we want
  181. to switch fonts.
  182.  
  183. 520 dreg(7)=28 : dreg(0)=FONT : trap 3
  184.  
  185. The variable FONT is the font we want to get the address of. STOS keeps
  186. two different numbers to represent the fonts. In Basic commands the
  187. values are 1-10 but when using this trap the values are 0-9. Values for
  188. FONT are:
  189.  
  190.         0       -Low res system font
  191.         1       -Medium res system font
  192.         2       -High res system font
  193.         3       -Loaded font 1 (or additional CR3 font)
  194.         4       -Loaded font 2 (or additional CR4 font)
  195.         ~       ~  ~     ~   ~  ~      ~       ~   ~
  196.         9       -Loaded font 9 (or additional CR9 font)
  197.  
  198.  
  199. Line 530 simply stores the address. After calling this trap 3 function
  200. the fonts address is stored in the pseudo register dreg(0). I've put it
  201. into a variable for clarity and to make sure that it's value doesn't
  202. change for some reason. You could use the dreg(0) directly.
  203.  
  204. 530 F_ADD=dreg(0)
  205.  
  206. Line 540 is VERY important. Obviously trying to replace an 8x8 font
  207. with a length of 2k with a 16x16 font with a length of 8k will result
  208. in a serious error. It will at best corrupt the text making everything
  209. unreadable or - more likely - crash the system. Using the command
  210. 'charlen' will return the real length of the font and we use this value
  211. to copy the correct number of bytes. Doing this means that only the
  212. font will be corrupted, but the system will survive. So remember a font
  213. can only be replaced with an equal sized or smaller sized font.
  214.  
  215. 540 CHL=charlen(FONT+1)
  216.  
  217. Line 550 does the bizz. It copies the block of memory that holds the
  218. font. to the address of the system font.
  219.  
  220. 550 copy start(BNK),start(BNK)+CHL to F_ADD
  221.  
  222. A calling example could be:
  223.  
  224. 10 BNK=5        Where is the NEW font? In this case bank 5
  225. 20 FONT=0       Which font to change? In this case low res
  226. 30 gosub 520    Go do it.
  227.  
  228. A further quite important point is to keep a copy of the font you have
  229. switched using 'charcopy' This is so you can restore the font if things
  230. go wrong or you just want to leave the system in the same state you
  231. found it. A line along the lines of:
  232.  
  233.               charcopy 1 to 6
  234.  
  235. Should do the trick. This copies the low res font into bank 6. In order
  236. to restore the font just set BNK to 6. The other system fonts will need
  237. different numbers - see above.
  238.  
  239. If you have other fonts already included using CR3 to CR9 then you can
  240. also find out the addresses of these fonts by using the numbers 3 to 9
  241. in the dreg(0)= definition. A value of '0' means that no font has been
  242. assigned.
  243.  
  244. Wanna be silly?
  245.  
  246. You can use ANY size of font as a default system font. Printing a line
  247. of text goes all over the place but it can be done. On the disk is a
  248. file called SILLY_FN.MBK, repeat the above procedure with this memory
  249. bank to see what I mean. Again NOTE: do NOT use your master disk for
  250. this purpose. Especially as it's a pointless font. Instead of 8x8.cr0
  251. it's best to call it 8x16.cr0, that way you'll remember what size it
  252. is!
  253.  
  254. This could be useful for when there is no reading text apart from
  255. titles and scores and stuff. Just use a big font instead of
  256. screencopying or whatever, STOS takes some of the donkey work out!! You
  257. have to take care that the text does not go off the edges of the screen
  258. as STOS may take a disliking to that. STOS assumes that if you are in
  259. low or medium res, that the font is going to be 8x8. If you use an 8x16
  260. or 16x16 then STOS gets more than a little confused and could crash.
  261.  
  262. Next time I've got a surprise. If you can slip this little bit of code
  263. into your STOS program it'll confuse everyone. Be there or
  264. be..triangular.
  265.  
  266.  
  267. Another shoddy article from Auld Bastid 1994
  268.  
  269.